<?
/*********************************************
*1626广告
* *******************************************/
function smarty_function_qishi_ad($params, &$smarty)
{ 
extract($params);
global $db,$_CFG;
$row = (NULL != $row) ? $row : 15; //默认显示记录数量
$start  = (NULL != $start) ? $start : 0; //从第几条开始读取，缺省0
$titlelen = (NULL != $titlelen) ? $titlelen : 15; //默认显示标题数量
$dot = (NULL != $dot) ? $dot : ''; //默认截取后填补字符
$typeid = (NULL != $typeid) ? $typeid : 1; //栏目ID
$listname = (NULL != $listname) ? $listname : "list"; //默认的循环变量名称
$settr = (NULL != $settr) ? $settr : ""; //时间范围
$wheresql=" WHERE category_id='".intval($typeid)."' ";
	if (intval($settr))
	{
	$settr_val=strtotime("-".$settr." day");
	$wheresql.=" AND addtime > ".$settr_val;
	}
	if(!empty($row))
	{
	$offset=$start?$start:0;
	$limit=" LIMIT ".$offset.','.$row;
	}
//排列字段
$orderby=ereg('show_order|id',$orderby)?$orderby:"show_order";
//显示顺序
$displayorder=ereg('asc|desc',$displayorder)?$displayorder:"DESC";
//sql语句
$orderbysql=" ORDER BY ".$orderby." ".$displayorder;
$result = $db->query("SELECT * FROM ".table('ad')." ".$wheresql.$orderbysql.$limit);
while($row = $db->fetch_array($result))
{
$row['title']=cut_str($row['title'],$titlelen,0,$dot);
$row['img']=$_CFG['upfiles_dir'].$row['img'];
$List[] = $row;
}
$smarty->assign($listname, $List);
unset($List);
}
?>